<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>项目上传</title>
    <!--<meta name="description" content="这是主页">-->
    <meta name="keywords" content="form">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" href="css/chinaz.css">
    <link rel="stylesheet" href="css/amazeui.swiper.min.css">


    <link rel="stylesheet" href="css/index.css">
    <!--<link rel="stylesheet" href="css/amazeui.slick.min.css">
    -->
    <!--<link rel="icon" type="image/png" href="assets/i/favicon.png">
    -->
    <!--<link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    -->
    <!--<meta name="apple-mobile-web-app-title" content="Amaze UI" />
    -->
    <link rel="stylesheet" href="assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="assets/css/layout.css"/>
    <!--<link rel="stylesheet" href="assets/css/admin.css">--></head>
<body>
<style>


    .objDetail {
        width: 23%;
        border-bottom: 1px solid #7c7c7c;
        margin-left: 2%;
        float: left;
        margin-bottom: 20px;
    }

    .am-pagination li a {
        border-radius: 4px;
        background-color: #dfe5e9;
        color: #7f8c8d;
    }
</style>
<!--<div style="background-color: #FFFFFF;height: 60px">-->
<!--    <img src="img/logo-06.png" id="layoutLogo" style="float: left;margin-left: 5%;margin-right: 30px">-->
<!---->
<!--    <div id='cssmenu' style="float: left">-->
<!--        <ul>-->
<!---->
<!--            <li class="">-->
<!--                <a href=-->
<!--                --><?//= Url::toRoute('index/show'); ?>
<!--                >首页</a>-->
<!--            </li>-->
<!---->
<!--            <li>-->
<!--                <a href=-->
<!--                --><?//= Url::toRoute('project/show'); ?>
<!--                >创业项目</a>-->
<!--            </li>-->
<!--            <li class=' has-sub'>-->
<!--                <a href=-->
<!--                --><?//= Url::toRoute('raised/show'); ?>
<!--                >项目聚幕</a>-->
<!--                <ul>-->
<!--                    <li class='has-sub sub-li'>-->
<!--                        <a href=-->
<!--                        --><?//= Url::toRoute('raised/show'); ?>
<!--                        >投资聚募</a>-->
<!--                    </li>-->
<!--                    <li class='has-sub sub-li'>-->
<!--                        <a href=-->
<!--                        --><?//= Url::toRoute('raised/select'); ?>
<!--                        >我要融资</a>-->
<!---->
<!--                    </li>-->
<!--                </ul>-->
<!--            </li>-->
<!--            <li class=' has-sub'>-->
<!--                <a href=-->
<!--                --><?//= Url::toRoute('basic-service/show-activity'); ?>
<!--                >基础服务</a>-->
<!--                <ul>-->
<!--                    <li class='has-sub sub-li'>-->
<!--                        <a href=-->
<!--                        --><?//= Url::toRoute('basic-service/show-activity'); ?>
<!--                        >线下活动</a>-->
<!--                    </li>-->
<!--                    <li class='has-sub sub-li'>-->
<!--                        <a href=-->
<!--                        --><?//= Url::toRoute('basic-service/show-information'); ?>
<!--                        >创业资讯</a>-->
<!--                    </li>-->
<!--                    <li class='has-sub sub-li'>-->
<!--                        <a href=-->
<!--                        --><?//= Url::toRoute('basic-service/show-business'); ?>
<!--                        >工商注册</a>-->
<!--                    </li>-->
<!--                    <li class='has-sub sub-li'>-->
<!--                        <a href=-->
<!--                        --><?//= Url::toRoute('basic-service/show-finance'); ?>
<!--                        >财务代办</a>-->
<!--                    </li>-->
<!--                    <li class='has-sub sub-li'>-->
<!--                        <a href=-->
<!--                        --><?//= Url::toRoute('basic-service/show-law'); ?>
<!--                        >法务咨询</a>-->
<!--                    </li>-->
<!--                </ul>-->
<!--            </li>-->
<!--        </ul>-->
<!--    </div>-->
<!--    <div class="isLogin">-->
<!--        <ul>-->
<!--            <li>-->
<!--                <img src="img/join.png">-->
<!--                <span>免费注册</span>-->
<!--            </li>-->
<!--            <li>-->
<!--                <img src="img/login.png" style="margin-top: -4px">-->
<!--                <span style="color: #3A99DB">登陆</span>-->
<!--            </li>-->
<!--        </ul>-->
<!--    </div>-->
<!--</div>-->
<div class="contextDiv" style="background-color: white">
    <div style="clear: both;background-color: white"></div>
    <div style="background-image: url(img/head.png);height: 160px;text-align: center;">
        <span style="font-size: 14px;display: inline-block;margin-top: 10px">简单三步上传项目</span>
        <div style="color: #7f8c8d;margin-top: 20px;margin-bottom: 10px;text-align: center">

                        <span id="b4"
                              style="width: 160px;height: 160px;font-size: 22px;color: white;background-color: #3A99DB;border-radius: 50%;text-align: center;padding:12px 16px 10px 16px"
                        >1</span>

            <img src="img/aiya.png" style="width: 100px;margin-left: 18px;margin-top: -10px;margin-right: 18px">

                         <span id="b5"
                               style="margin-left: 8px;width: 160px;height: 160px;font-size: 22px;color: #7c7c7c;background-color: inherit;border:1px solid #7c7c7c;border-radius: 50%;text-align: center;padding:12px 16px 10px 16px"
                         >2</span>
            <img src="img/aiya.png" style="width: 100px;margin-left: 18px;margin-top: -10px;margin-right: 18px">



                         <span id="b6"
                               style="margin-left: 8px;width: 160px;height: 160px;font-size: 22px;color: #7c7c7c;background-color: inherit;border:1px solid #7c7c7c;border-radius: 50%;text-align: center;padding:12px 16px 10px 16px"
                         >3</span>
        </div>
        <div style="text-align: center">
            <span style="font-size: 14px">基本情况</span>
            <span style="font-size: 14px;margin-left: 136px">项目细节</span>
            <span style="font-size: 14px;margin-left: 136px">联系信息</span>
        </div>
    </div>
    <?php $form = ActiveForm::begin(['id' => 'form1','options' => ['enctype' => 'multipart/form-data','target' => 'q']]) ?>
    <div style="background-color: #eff3f5;min-height: 600px;padding-top: 30px">
        <div style="background-color: white;border: 1px solid #dddddd;width:80%;min-height: 540px;margin-left: 10%;padding-top: 54px;padding-bottom: 54px">
            <div style="width: 50%;background-color: rgb(254,238,191);height: 110px;padding-top: 22px;padding-left:4%;padding-right: 4%;margin-left: 25%">
                <span>
                    您的信息不会透露给任何第三方,我们会与您联系确认适合公开的项目信息.
                </span>
            </div>
            <div id="info">
                <div style="margin-left: 25%;width: 100%">
                    <h5 style="margin-bottom: 4px;margin-top: 20px">项目名称:</h5>
                    <input id="title" placeholder="请输入1-20个字符"
                           style="height: 40px;width: 22%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)">
                </div>

                <div style="margin-left: 25%;float: left;width: 24%">
                    <h5 style="margin-bottom: 4px;margin-top: 20px">项目类型:</h5>
                    <select placeholder="请输入1-20个字符"
                            style="height: 40px;width: 90%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="field">
                        <?php foreach ($fields as $field): ?>
                         <option id="
                             <?= Html::encode($field->field_id) ?>
                         ">
                             <?= Html::encode($field->field_name) ?>
                         </option>
                     <?php endforeach; ?> 
                    </select>

                </div>
                <div style=";float: left;width: 22%">
                    <h5 style="margin-bottom: 4px;margin-top: 20px">项目所在地:</h5>
                    <select class="getProvince" onchange="getCities()" placeholder="请输入1-20个字符"
                            style="height: 40px;width: 45%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="province">
                        <?php foreach ($provinces as $province): ?>
                         <option id="
                             <?= Html::encode($province->id) ?>
                         ">
                             <?= Html::encode($province->province) ?>
                         </option>
                     <?php endforeach; ?>
                    </select>
                    <select class="getCities" placeholder="请输入1-20个字符"
                            style="margin-left: 5%;height: 40px;width: 45%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="city">
                        <?php foreach ($cities as $city): ?>
                         <option>
                             <?= Html::encode($city->province) ?>
                         </option>
                     <?php endforeach; ?> 
                    </select>

                </div>
                <div style="clear: both"></div>
                <div style="margin-left: 25%;width: 100%">
                    <h5 style="margin-bottom: 4px;margin-top: 20px">是否准备好详细的项目计划书?</h5>
                    <input onclick="bb()" type="radio" name="pro" value="no" style="margin-right: 10px">还没有
                    <input onclick="aa()" type="radio" name="pro" value="yes"
                           style="margin-left: 20px;margin-right: 10px">已经准备好
                    <div style="margin-top: 10px;display: none" id="file">
                        <div class="form-group field-projectuploadform-projectplan">
                <input type="hidden" name="ProjectUploadForm[projectPlan]" value="">
                <input type="file" id="projectuploadform-projectplan" name="ProjectUploadForm[projectPlan]">
                <div class="help-block"></div>
            </div>
                    </div>
                    <script>
                        function aa() {
                            $('#file').css('display', '')
                        }
                        function bb() {
                            $('#file').css('display', 'none')
                        }
                    </script>
                    <div style="margin-top: 20px;text-align: left">
                        <button id="next"
                                style="height:40px;font-size: 20px;outline: none;width: 10%;border:none;color:white;border-bottom: 2px solid rgb(29,114,158);margin-top: 0px;background-color: #55B6E4" type="button">
                            下一步
                        </button>
                    </div>
                </div>
            </div>

        </div>
    </div>
<?php ActiveForm::end() ?>
<iframe name="q" style="width:0; height:0; margin-top:-10px;"></iframe>
</div>
<div style="clear: both"></div>
<!--<footer style="background-color: #FFFFFF;height: 100px;width: 100%;margin-bottom: 20px">-->
<!--    <img src="img/logo-06.png" class="layoutLogo"-->
<!--         style="float: left;margin-left: 5%;margin-top:12px;margin-right: 30px">-->
<!--    <ul class="footUl">-->
<!--        <li><a href="#">商务合作</a></li>-->
<!--        <li><a href="#">常见问题</a></li>-->
<!--        <li><a href="#">关于我们</a></li>-->
<!--        <li><a href="#">业务规划</a></li>-->
<!--        <li><a href="#">联系我们</a></li>-->
<!--        <li><a href="#">免责声明</a></li>-->
<!--    </ul>-->
<!--    <img src="img/erweima.jpg" style="width: 80px;float: right;margin-right: 5%;margin-top:18px">-->
<!--</footer>-->
</body>
<script src="assets/js/jquery.min.js"></script>
<script src="js/index.js"></script>
<!--<![endif]-->
<script src="assets/js/amazeui.min.js"></script>
<!--<script src="js/chinaz.js"></script>-->
<script src="js/amazeui.swiper.min.js"></script>
<!--<script src="js/slick.min.js"></script>
-->
<!--<script src="assets/js/app.js"></script>
-->
</html>
<script>

var title;
var field;
var province;
var city;
var leaderName;
var mobile;
var email;
var weixin;
var description;
var market;
var merits;
var business;
var finance;
var member;
var demand;
var projectPlan="";
var externalImage="";
var insideImage="";

function change(id)
   {
       var file=$("#"+id).val(); 
       var filename=file.replace(/.*(\/|\\)/, ""); 
       var fileExt=(/[.]/.exec(filename)) ? /[^.]+$/.exec(filename.toLowerCase()) : '';
       return fileExt;
   }

    $(document).on('click', '#next', function () {
        title = $("#title").val();
        field = $("#field").val();
        province = $("#province").val();
        city = $("#city").val();
        if($("#projectuploadform-projectplan").val() != "")
        {
            projectPlan = 'uploads/' + '<?php echo $_COOKIE["user_id"] ?>' + 'project' + 'projectPlan' + '.' +change("projectuploadform-projectplan");
        }
        document.getElementById("form1").submit();

        $('#b4').css({'background-color': 'inherit', 'color': '#7c7c7c', 'border': '1px solid #7c7c7c'});
        $('#b5').css({
            'background-color': '#3A99DB',
            'color': 'white',
            'border': 'none'
        });
        $('#info').html('<div style="margin-left: 25%;width: 100%"> ' +
                '<h5 style="margin-bottom: 4px;margin-top: 10px">项目描述:</h5> ' +
                '<textarea placeholder="请输入1-800个字符" ' +
                'style="height: 200px;width: 50%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="description">' +

                '</textarea>' +
                '<h5 style="margin-bottom: 4px;margin-top: 10px">市场分析:</h5> ' +
                '<textarea placeholder="请输入1-800个字符" ' +
                'style="height: 200px;width: 50%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="market">' +

                '</textarea>' +
                '<h5 style="margin-bottom: 4px;margin-top: 10px">优势劣势分析:</h5> ' +
                '<textarea placeholder="请输入1-800个字符" ' +
                'style="height: 200px;width: 50%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="merits">' +

                '</textarea>' +
                '<h5 style="margin-bottom: 4px;margin-top: 10px">商业模式:</h5> ' +
                '<textarea placeholder="请输入1-800个字符" ' +
                'style="height: 200px;width: 50%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="business">' +

                '</textarea>' +
                '<h5 style="margin-bottom: 4px;margin-top: 10px">财务情况:</h5> ' +
                '<textarea placeholder="请输入1-800个字符" ' +
                'style="height: 200px;width: 50%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="finance">' +

                '</textarea>' +
                '<h5 style="margin-bottom: 4px;margin-top: 10px">请填写招募的团队成员:<span style="color:#DDDDDD">(例:前端开发,产品经理)</span></h5> ' +
                '<input placeholder="请输入1-2icon1.png0个字符" ' +
                'style="height: 40px;width: 50%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="member">' +

                '</input>' +
                '<h5 style="margin-bottom: 4px;margin-top: 10px">详细招募需求:</h5> ' +
                '<textarea placeholder="请输入1-20个字符" ' +
                'style="height: 200px;width: 50%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="demand">' +

                '</textarea>' +
                '<h5 style="margin-bottom: 14px;margin-top: 10px">页面展示图片:</h5> ' +
                '<h5 style="margin-bottom: 10px;margin-top: 0px;color:#7c7c7c">页面展示图片x1*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;尺寸:xxx*xxx</h5> ' +

                '<div class="form-group field-projectuploadform-externalimage">'+
'<input type="hidden" name="ProjectUploadForm[externalImage]" value=""><input type="file" id="projectuploadform-externalimage" name="ProjectUploadForm[externalImage]">'+
'<div class="help-block"></div>'+
'</div>'+
                '<h5 style="margin-bottom: 10px;margin-top: 20px;color:#7c7c7c">页面内页显示图片x1*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;尺寸:xxx*xxx</h5> ' +

                '<div class="form-group field-projectuploadform-insideimage">'+
'<input type="hidden" name="ProjectUploadForm[insideImage]" value=""><input type="file" id="projectuploadform-insideimage" name="ProjectUploadForm[insideImage]">'+
'<div class="help-block"></div>'+
'</div>'+
                '<div style="margin-top: 20px;text-align: left"> ' +
                '<button id="next1"' +
                'style="height:40px;font-size: 20px;outline: none;width: 10%;border:none;color:white;border-bottom: 2px solid rgb(29,114,158);margin-top: 0px;background-color: #55B6E4" type="button">' +
                '下一步 ' +
                '</button>' +
                '</div>' +
                '</div>')
    });
    $(document).on('click','#next1',function () {
        description = $("#description").val();
        market = $("#market").val();
        merits = $("#merits").val();
        business = $("#business").val();
        finance = $("#finance").val();
        member = $("#member").val();
        demand = $("#demand").val();

        if($("#projectuploadform-externalimage").val() != "")
        {
            externalImage = 'uploads/' + '<?php echo $_COOKIE["user_id"] ?>' + 'project' + 'externalImage' + '.' +change("projectuploadform-externalimage");
        }
        if($("#projectuploadform-insideimage").val() != "")
        {
            insideImage = 'uploads/' + '<?php echo $_COOKIE["user_id"] ?>' + 'project' + 'insideImage' + '.' +change("projectuploadform-insideimage");
        }
        document.getElementById("form1").submit();
        $('#info').html('<div style="margin-left: 25%;float: left;width: 24%"> ' +
                '<h5 style="margin-bottom: 4px;margin-top: 20px"><span style="color: red">*</span>项目负责人姓名:</h5> ' +
                '<input placeholder="姓名"' +
                'style="height: 40px;width: 90%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="leaderName"> ' +
                '</div> ' +
                '<div style=";float: left;width: 22%"> ' +
                '<h5 style="margin-bottom: 4px;margin-top: 20px"><span style="color: red">*</span>联系电话:</h5> ' +
                '<input placeholder="电话"' +
                'style="height: 40px;width: 90%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="mobile"> ' +
                '</div>' +
                '<div style="clear: both"></div>'+
                '<div style="margin-left: 25%;float: left;width: 24%"> ' +
                '<h5 style="margin-bottom: 4px;margin-top: 20px"><span style="color: red">*</span>E-mail:</h5> ' +
                '<input placeholder="邮箱"' +
                'style="height: 40px;width: 90%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="email"> ' +
                '</div> ' +
                '<div style=";float: left;width: 22%"> ' +
                '<h5 style="margin-bottom: 4px;margin-top: 20px"><span style="color: red">*</span>微信:</h5> ' +
                '<input placeholder="微信"' +
                'style="height: 40px;width: 90%;padding: 6px;outline: none;background-color: rgb(240,240,240);color: black;border-radius: 4px;border: 1px solid rgb(171,171,173)" id="weixin"> ' +
                '</div>' +
                '<div style="clear: both;height: 10px;margin-bottom: 1px"></div>'+
                '<div style="margin-top: 20px;text-align: center"> ' +
                '<button id="next2"' +
                'style="height:40px;font-size: 20px;outline: none;width: 10%;border:none;color:white;border-bottom: 2px solid rgb(29,114,158);margin-top: 0px;background-color: #55B6E4" type="submit">' +
                '提交 ' +
                '</button>' +

                '</div>'
        );
    })

$(document).on('click','#next2',function () {
        
        leaderName = $("#leaderName").val();
        mobile = $("#mobile").val();
        email = $("#email").val();
        weixin = $("#weixin").val();
        $.get(
             "<?= Url::toRoute('upload/insert-project'); ?>",
             {'title':title,'field':field,'province':province,'city':city,'leaderName':leaderName,'mobile':mobile,'email':email,'weixin':weixin,'description':description,'market':market,'merits':merits,'business':business,'finance':finance,'member':member,'demand':demand,'projectPlan':projectPlan,'externalImage':externalImage,'insideImage':insideImage},
            function(data){
                 //alert(data);
                 alert("信息上传成功！");
            });
        //document.getElementById("form1").submit();
    });

function getCities(){
        var selectObj = $(".getProvince")[0];
        var optionObj = selectObj.options[selectObj.selectedIndex];
        var father_id = optionObj.id;
        //$.get("<?= Url::toRoute('upload/getCity'); ?>",
        $.getJSON("<?= Url::toRoute('upload/city'); ?>",
            {'father_id':father_id},
            function(data){
                var realData = data;
                var count = realData.length;
                    $(".getCities").empty();
                for(var i=0;i<count;i++)
                {
                    $(".getCities").append("<option>"+realData[i]['province']+"</option>")
                }
            });
    };

$('.control-label').text('');
    $('#uploadform-file').css('display', 'inline');

</script>